using UnityEngine;
using QFramework;

namespace QFramework.Monk
{
	public partial class EnemyFly : EnemyBase
	{
		private float mRad;
		private float mAngle;
		protected override void Move()
		{
			if (!AppStart.CheckGameState(GameState.GamePlaying))
			{
				return;
			}
			// 空指针检查
			if (Player.Default != null)
			{
				mAngle += Time.deltaTime * 60;
				if (mAngle > 360)
				{
					mAngle = 0;
				}
				mRad = mAngle.Deg2Rad();
				// 方向 做sin曲线运动
				var dir = (Player.Default.transform.position - this.transform.position).normalized ;
				dir = (dir + Mathf.Sin(mRad) * Vector3.up*mSpeed);
				selfRigidbody2D.velocity = dir;
			}
			else
			{
				selfRigidbody2D.velocity = Vector2.zero;
			}
		}
	}
}
